﻿using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace Luka;

/// <summary>
/// 注入基础配置
/// </summary>
[NotScanned]
internal static class BaseServiceCollection
{
    /// <summary>
    /// 默认服务
    /// </summary>
    public static void AddDefaultServiceCollection(this IServiceCollection services)
    {
        //Cors
        services.AddCors();

        //Swagger
        services.AddSwagger();

        //注册服务
        services.AddRegisterService();

        //Sqlsugar
        services.AddSqlsugar();

        //Mapster
        services.AddMapster();

        //路由约束
        services.AddRouteConvention();

        //Startup扩展
        services.AddTransient<IStartupFilter, StartupFilter>();

        // 插入到最后一个位置,确保 StartupFilter 总是最后一个注册的服务。
        services.Insert(services.Count - 1, ServiceDescriptor.Transient<IStartupFilter, StartupFilter>());
    }
}